{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 模型训练  \n",
    "1.Tree模型  \n",
    "2.LightGBM模型  \n",
    "3.调参  \n",
    "4.最终模型  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from lightgbm.sklearn import LGBMClassifier\n",
    "from xgboost import XGBClassifier\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import roc_auc_score\n",
    "from sklearn import metrics\n",
    "from sklearn.model_selection import KFold\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "import lightgbm\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dpath = \"./data/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_final = pd.read_csv(dpath+\"train_final.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>msno</th>\n",
       "      <th>song_id</th>\n",
       "      <th>source_system_tab</th>\n",
       "      <th>source_screen_name</th>\n",
       "      <th>source_type</th>\n",
       "      <th>city</th>\n",
       "      <th>bd</th>\n",
       "      <th>gender</th>\n",
       "      <th>registered_via</th>\n",
       "      <th>registration_init_time</th>\n",
       "      <th>...</th>\n",
       "      <th>song_length</th>\n",
       "      <th>genre_ids</th>\n",
       "      <th>language</th>\n",
       "      <th>mult_genre</th>\n",
       "      <th>user_pop</th>\n",
       "      <th>item_pop</th>\n",
       "      <th>user_rate</th>\n",
       "      <th>item_rate</th>\n",
       "      <th>lfm_reco</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>FGtllVqz18RPiwJj/edr2gV78zirAiY/9SmYvia+kCg=</td>\n",
       "      <td>BBzumQNXUHKdEBOB7mAJuzok+IJA1c2Ryg/yzTF6tik=</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.25183</td>\n",
       "      <td>17</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>15.581</td>\n",
       "      <td>0.795</td>\n",
       "      <td>0.506</td>\n",
       "      <td>0.474</td>\n",
       "      <td>0.53734</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=</td>\n",
       "      <td>bhp/MpSNoqoxOIB+/l8WPqu6jldth4DIpCm3ayXnJqM=</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>0.23361</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>1.991</td>\n",
       "      <td>-0.081</td>\n",
       "      <td>0.743</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.99810</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=</td>\n",
       "      <td>JNWfrrC7zNN7BdMpsISKa4Mw+xVJYNnxXh3/Epw7QgY=</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.13422</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>1.991</td>\n",
       "      <td>-0.072</td>\n",
       "      <td>0.743</td>\n",
       "      <td>0.500</td>\n",
       "      <td>-0.04898</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=</td>\n",
       "      <td>2A87tzfnJTSWqD7gIZHisolhe4DMdzkbd6LzO1KHjNs=</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>0.05294</td>\n",
       "      <td>40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.991</td>\n",
       "      <td>-0.081</td>\n",
       "      <td>0.743</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.99810</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>FGtllVqz18RPiwJj/edr2gV78zirAiY/9SmYvia+kCg=</td>\n",
       "      <td>3qm6XTZ6MOCU11x8FIVbAGH5l5uMkT3/ZalWG1oo2Gc=</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.36784</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>15.581</td>\n",
       "      <td>1.211</td>\n",
       "      <td>0.506</td>\n",
       "      <td>0.364</td>\n",
       "      <td>0.38750</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           msno  \\\n",
       "0  FGtllVqz18RPiwJj/edr2gV78zirAiY/9SmYvia+kCg=   \n",
       "1  Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=   \n",
       "2  Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=   \n",
       "3  Xumu+NIjS6QYVxDS4/t3SawvJ7viT9hPKXmf0RtLNx8=   \n",
       "4  FGtllVqz18RPiwJj/edr2gV78zirAiY/9SmYvia+kCg=   \n",
       "\n",
       "                                        song_id  source_system_tab  \\\n",
       "0  BBzumQNXUHKdEBOB7mAJuzok+IJA1c2Ryg/yzTF6tik=                  1   \n",
       "1  bhp/MpSNoqoxOIB+/l8WPqu6jldth4DIpCm3ayXnJqM=                  3   \n",
       "2  JNWfrrC7zNN7BdMpsISKa4Mw+xVJYNnxXh3/Epw7QgY=                  3   \n",
       "3  2A87tzfnJTSWqD7gIZHisolhe4DMdzkbd6LzO1KHjNs=                  3   \n",
       "4  3qm6XTZ6MOCU11x8FIVbAGH5l5uMkT3/ZalWG1oo2Gc=                  1   \n",
       "\n",
       "   source_screen_name  source_type  city  bd  gender  registered_via  \\\n",
       "0                   6            5     1   0       2               7   \n",
       "1                   7            3    13   4       0               9   \n",
       "2                   7            3    13   4       0               9   \n",
       "3                   7            3    13   4       0               9   \n",
       "4                   6            5     1   0       2               7   \n",
       "\n",
       "   registration_init_time   ...    song_length  genre_ids  language  \\\n",
       "0                       8   ...       -0.25183         17         8   \n",
       "1                       7   ...        0.23361          6         8   \n",
       "2                       7   ...       -0.13422          6         8   \n",
       "3                       7   ...        0.05294         40         0   \n",
       "4                       8   ...       -0.36784          1         8   \n",
       "\n",
       "   mult_genre  user_pop  item_pop  user_rate  item_rate  lfm_reco  target  \n",
       "0           0    15.581     0.795      0.506      0.474   0.53734       1  \n",
       "1           0     1.991    -0.081      0.743      1.000   0.99810       1  \n",
       "2           0     1.991    -0.072      0.743      0.500  -0.04898       1  \n",
       "3           0     1.991    -0.081      0.743      1.000   0.99810       1  \n",
       "4           0    15.581     1.211      0.506      0.364   0.38750       1  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_final.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>lfm_reco</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1764</th>\n",
       "      <td>0.62223</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1773</th>\n",
       "      <td>0.48771</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1774</th>\n",
       "      <td>0.24954</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1776</th>\n",
       "      <td>0.07624</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1777</th>\n",
       "      <td>0.02516</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1778</th>\n",
       "      <td>0.01992</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1779</th>\n",
       "      <td>-0.09002</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1780</th>\n",
       "      <td>-0.10330</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1781</th>\n",
       "      <td>-0.06710</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1782</th>\n",
       "      <td>-0.17358</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1783</th>\n",
       "      <td>-0.07624</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1784</th>\n",
       "      <td>-0.06381</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1806</th>\n",
       "      <td>0.41079</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1817</th>\n",
       "      <td>0.44157</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1818</th>\n",
       "      <td>0.38588</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1819</th>\n",
       "      <td>0.42429</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1820</th>\n",
       "      <td>0.48273</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1826</th>\n",
       "      <td>0.58954</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1829</th>\n",
       "      <td>0.82662</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1830</th>\n",
       "      <td>0.63481</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1831</th>\n",
       "      <td>0.78510</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1845</th>\n",
       "      <td>0.45003</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1846</th>\n",
       "      <td>0.46898</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1849</th>\n",
       "      <td>0.54628</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1854</th>\n",
       "      <td>0.64280</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1870</th>\n",
       "      <td>0.85325</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1872</th>\n",
       "      <td>-0.75173</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1873</th>\n",
       "      <td>0.99475</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1874</th>\n",
       "      <td>0.53071</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1884</th>\n",
       "      <td>0.30795</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      lfm_reco  target\n",
       "1764   0.62223       0\n",
       "1773   0.48771       0\n",
       "1774   0.24954       0\n",
       "1776   0.07624       0\n",
       "1777   0.02516       0\n",
       "1778   0.01992       0\n",
       "1779  -0.09002       0\n",
       "1780  -0.10330       0\n",
       "1781  -0.06710       0\n",
       "1782  -0.17358       0\n",
       "1783  -0.07624       0\n",
       "1784  -0.06381       0\n",
       "1806   0.41079       0\n",
       "1817   0.44157       0\n",
       "1818   0.38588       0\n",
       "1819   0.42429       0\n",
       "1820   0.48273       0\n",
       "1826   0.58954       0\n",
       "1829   0.82662       0\n",
       "1830   0.63481       0\n",
       "1831   0.78510       0\n",
       "1845   0.45003       0\n",
       "1846   0.46898       0\n",
       "1849   0.54628       0\n",
       "1854   0.64280       0\n",
       "1870   0.85325       0\n",
       "1872  -0.75173       0\n",
       "1873   0.99475       0\n",
       "1874   0.53071       0\n",
       "1884   0.30795       0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_final[train_final.target==0].iloc[300:330,-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7377403, 21)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_final.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.Tree模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.array(train_final.iloc[:,2:-1])\n",
    "y = np.array(train_final.iloc[:,-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 1min 31s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "treeclf = DecisionTreeClassifier(max_depth=8,min_samples_split=50,random_state=6)\n",
    "treeclf.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_pred = treeclf.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7031936577139679"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "accuracy_score(y_pred,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_proba = treeclf.predict_proba(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "fpr,tpr,thresholds = metrics.roc_curve(y,y_proba[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7802130707544989"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "metrics.auc(fpr, tpr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8leWd9/HPLwmEBAIBQlgCISxBQNwggvu+oHVkqtbBtmpdW1v1mdppaztPW8fOtNN2HOfpa6yVVtxxryMqrVr3jR1BWQ1bEtYEkgDZc87v+eMcM2lMSIDcOTk53/frlRfnPveV+/zuJJzvue7luszdERERAUiKdQEiItJ9KBRERKSJQkFERJooFEREpIlCQUREmigURESkiUJBRESaKBRERKSJQkEShpmlxLqGlrpjTZLYFArSo5nZFjP7oZmtAqrMLMXMJpnZ22ZWYWarzezSZu3TzOweM9tqZpVm9r6Zp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gY//OAT2JasMghUE9B5DBEx1MqAG4FvkxkbKW+ROYymEFkeIlXgCkd6U2IdBfqKYgcuRfdvcbdy4C3iMwBALBYgSDxRqEgcuRadrc/X67q6kJEjpRCQeTIzTKzPmY2mMhAZktiXI/IYVMoiBy5xUTOHywEfu7ucT0dpCQ2nWgWOQJmdhdwwN3/I9a1iHQG9RRERKSJegoiItJEPQUREWmiUBARkSYKBRERaaJQEBGRJgoFERFp8v8BHcTlMXo3tPYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = fpr \n",
    "y = tpr\n",
    "plt.title(\"roc curve\") \n",
    "plt.xlabel(\"fpr\") \n",
    "plt.ylabel(\"tpr\") \n",
    "plt.plot(x,y) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([7.12665196e-04, 6.08773979e-03, 8.19941977e-02, 0.00000000e+00,\n",
       "       0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 8.18349252e-06,\n",
       "       0.00000000e+00, 1.08159088e-06, 2.30726707e-04, 0.00000000e+00,\n",
       "       0.00000000e+00, 6.90399722e-03, 1.24339986e-02, 5.45440088e-01,\n",
       "       3.28341455e-01, 1.78458670e-02])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "treeclf.feature_importances_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.lightgbm模型  \n",
    "默认参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.array(train_final.iloc[:,2:-1])\n",
    "y = np.array(train_final.iloc[:,-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 1min 2s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "lgbm = LGBMClassifier(silent=False)\n",
    "lgbm.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_pred = lgbm.predict(X)\n",
    "y_proba = lgbm.predict_proba(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.61523836, 0.99948388, 0.75715806, ..., 0.77813072, 0.57034259,\n",
       "       0.66092279])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_proba[:,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7134505191054359"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "accuracy_score(y_pred,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "fpr,tpr,thresholds = metrics.roc_curve(y,y_proba[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7921882588995087"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "metrics.auc(fpr, tpr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmc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umrwsROVUKBZFTd4mZDTazNNomMlsfcj0iJ02hIHLq3qDt/MFa4HvuHtXLQUps04lmkVNgZt8Fqt39R2HXItIb1FMQEZF26imIiEg79RRERKSdQkFERNopFEREpJ1CQURE2ikURESk3f8C9mdihF6wmn8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot as plt \n",
    "x = fpr \n",
    "y = tpr\n",
    "plt.title(\"roc\") \n",
    "plt.xlabel(\"fpr\") \n",
    "plt.ylabel(\"tpr\") \n",
    "plt.plot(x,y) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([134, 265, 315,  30,  75,   9,  32,  67,  16,  18,  76,  88,   1,\n",
       "       339, 348, 464, 475, 248])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lgbm.feature_importances_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.调参  \n",
    "机器性能有限，只尝试用部分数据调参，请直接看第4模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_sample = train_final.sample(frac=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(737740, 21)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_sample.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.array(train_sample.iloc[:,2:-1])\n",
    "y = np.array(train_sample.iloc[:,-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "kfold = StratifiedKFold(n_splits=3, shuffle=True, random_state=6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### (1) n_estimators"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_n_estimators(params,X,y): \n",
    "    train_set = lightgbm.Dataset(X,y)\n",
    "    cv_result = lightgbm.cv(params,train_set,num_boost_round=1000,nfold=3,\\\n",
    "                        metrics='auc',early_stopping_rounds=10,seed=6)\n",
    "     \n",
    "    print('best n_estimators:' , len(cv_result['auc-mean']))\n",
    "    print('best cv score:' , cv_result['auc-mean'][-1])\n",
    "     \n",
    "    return cv_result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "best n_estimators: 1000\n",
      "best cv score: 0.8077677933485231\n",
      "Wall time: 26min 19s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "params = {'boosting_type': 'gbdt',\n",
    "          'n_jobs': 4,\n",
    "          'objective': 'binary',\n",
    "          'learning_rate': 0.1,\n",
    "          'max_depth': 10,\n",
    "          'num_leaves': 80,\n",
    "          'max_bin': 127,\n",
    "          'subsample': 0.8,\n",
    "          'bagging_freq': 1,\n",
    "          'colsample_bytree': 0.7,\n",
    "         }\n",
    "\n",
    "cv_result = get_n_estimators(params,X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEXCAYAAACH/8KRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xt8VdWd9/HPL4EEciEhkEACCdeAICDa4L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gX9U5X2zzE5QTLdB8BXgduD8s/QDB0VNNZuZlNcvc17v5tghV7zwGOApmnGcvrwK1mlmxmuQS9ineAHcB0M0sNe0DXRHmstlhvIFg9WOQUOstDBpL/BzxjZp8AlvTicQ+b2ZsE90n/ZFj2AMFtblcD9Zy8V0Rn5V8ws6sIegTrgRcJekPNZrYKeKqbeZI2zxHMmawi6E18xYN7k2BmzxAsKb8FWBHFsb4JPG1m7xIMke2MYh8ZgLSMvIiI9IiGtkREpEc0tCUSBTN7hODe75G+5+5PnqX3/yDw7XbF29z9z87G+4t0RUNbIiLSIxraEhGRHlEiERGRHlEiERGRHlEiERGRHvn/zFY56Hb91tEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(1000) \n",
    "y = cv_result[\"auc-mean\"]\n",
    "plt.title(\"cv_result\") \n",
    "plt.xlabel(\"num_boost_round\") \n",
    "plt.ylabel(\"auc-mean\") \n",
    "plt.plot(x,y) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### (2) num_leaves & max_depth=7"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Found input variables with inconsistent numbers of samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting 3 folds for each of 1 candidates, totalling 3 fits\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=4)]: Using backend LokyBackend with 4 concurrent workers.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 37.1 s\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=4)]: Done   3 out of   3 | elapsed:   36.7s remaining:    0.0s\n",
      "[Parallel(n_jobs=4)]: Done   3 out of   3 | elapsed:   36.7s finished\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "params = {'boosting_type': 'gbdt',\n",
    "          'objective': 'binary',\n",
    "          'n_jobs': 4,\n",
    "          'learning_rate': 0.1,\n",
    "          'n_estimators':300,\n",
    "          'max_depth': 9,\n",
    "          'max_bin': 127,\n",
    "          'subsample': 0.7,\n",
    "          'bagging_freq': 1,\n",
    "          'colsample_bytree': 0.7,\n",
    "         }\n",
    "lgbm = LGBMClassifier(silent=False,**params)\n",
    "\n",
    "num_leaves = range(70,80,10)\n",
    "tuned_params = dict( num_leaves = num_leaves)\n",
    "\n",
    "gridcv = GridSearchCV(lgbm, n_jobs=4, param_grid=tuned_params,\\\n",
    "                           cv = kfold, scoring=\"roc_auc\", verbose=5, refit = False)\n",
    "gridcv.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7937268175455278\n"
     ]
    }
   ],
   "source": [
    "print(gridcv.best_score_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'num_leaves': 70}\n"
     ]
    }
   ],
   "source": [
    "print(gridcv.best_params_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. 最终模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.array(train_final.iloc[:,2:-1])\n",
    "y = np.array(train_final.iloc[:,-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "设置参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "params = {'boosting_type': 'gbdt',\n",
    "          'objective': 'binary',\n",
    "          'n_jobs': 4,\n",
    "          'learning_rate': 0.05,\n",
    "          'n_estimators':500,\n",
    "          'max_depth': 8,\n",
    "          'num_leaves': 80,\n",
    "          'max_bin': 127,\n",
    "          'subsample': 0.7,\n",
    "          'bagging_freq': 3,\n",
    "          'colsample_bytree': 1,\n",
    "          'reg_alpha':1,\n",
    "          'reg_lambda':1,\n",
    "         }"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 4.1 交叉验证"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "def validate():\n",
    "    accuracys = []\n",
    "    aucs = []\n",
    "    fprs = []\n",
    "    tprs = []\n",
    "    iteration = 0\n",
    "    kfold = KFold(n_splits=3)\n",
    "    for train_index, val_index in kfold.split(X):\n",
    "        X_train, X_val = X[train_index], X[val_index]\n",
    "        y_train, y_val = y[train_index], y[val_index]\n",
    "        lgbm_cv = LGBMClassifier(silent=False,**params)\n",
    "        lgbm_cv.fit(X_train,y_train)\n",
    "        y_pred = lgbm_cv.predict(X_val)\n",
    "        y_proba = lgbm_cv.predict_proba(X_val)\n",
    "        #计算accuracy\n",
    "        accuracy = accuracy_score(y_pred,y_val)\n",
    "        accuracys.append(accuracy)\n",
    "        #计算auc\n",
    "        fpr,tpr,thresholds = metrics.roc_curve(y_val,y_proba[:,1],pos_label=1)\n",
    "        fprs.append(fpr)\n",
    "        tprs.append(tpr)\n",
    "        auc = metrics.auc(fpr, tpr)\n",
    "        aucs.append(auc)\n",
    "        print(\"iteration %d: accuracy %f, auc %f\"%(iteration,accuracy,auc))\n",
    "        iteration += 1\n",
    "    avg_accuracy = round(sum(accuracys)/3,5)\n",
    "    avg_auc = round(sum(aucs)/3,5)\n",
    "    avg_fpr = list(map(lambda x: (x[0]+x[1]+x[2])/3,zip(fprs[0],fprs[1],fprs[2])))\n",
    "    avg_tpr = list(map(lambda x: (x[0]+x[1]+x[2])/3,zip(tprs[0],tprs[1],tprs[2])))\n",
    "    return avg_accuracy,avg_auc,avg_fpr,avg_tpr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "平均auc和accuracy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iteration 0: accuracy 0.735106, auc 0.821309\n",
      "iteration 1: accuracy 0.700678, auc 0.776844\n",
      "iteration 2: accuracy 0.681979, auc 0.752568\n",
      "Wall time: 13min 13s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "avg_accuracy,avg_auc,avg_fpr,avg_tpr = validate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.70592, 0.78357)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "avg_accuracy,avg_auc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "roc curve"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEXCAYAAABCjVgAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl4lPW9/vH3JxskgRAgrIEQ9kXEhYCgHouCSt1brcXaup5a26pdtT3VttYup6v+7FW7YKtytFVxqWJFra2oVUEIyC5hCYGENRBIIJCQZD6/P2aMMQYyIZnMJHO/risXs3zzzJ0hee55dnN3REREABKiHUBERGKHSkFEROqpFEREpJ5KQURE6qkURESknkpBRETqqRRERKSeSkFEROqpFCSumFlStDM0FouZJH6pFKTTM7MiM/uOma0EKs0syczGmtnrZrbfzNaY2SUNxqea2W/MbIuZlZvZW2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k+Mw2s3EEtzvMCacQRDoCLSmItBEzewA4o9HD97v7w9HII3I8VAoiIlJPG5pFRKSeSkFEROqpFEREpJ5KQURE6v1/tiW8OTst/Q4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.title(\"roc curve\") \n",
    "plt.xlabel(\"avg_fpr\") \n",
    "plt.ylabel(\"avg_tpr\") \n",
    "plt.plot(avg_fpr,avg_tpr) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 4.2 训练  \n",
    "全部训练数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 4min 40s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "lgbm = LGBMClassifier(**params,silent=False,random_state=6)\n",
    "lgbm.fit(X,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "roc curve"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_proba = lgbm.predict_proba(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "fpr,tpr,thresholds = metrics.roc_curve(y,y_proba[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8leWZ//HPlYQshC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VsSm3S3Tmd/sPRE4qwMxyiQwn7ejWKrtWZ7a5GLgIwMwmEQmF8m6tsnstBq6NnoU0Czjs7vu6auV9bvjI3ZvN7EZgKZEzFx5w9w1mdjuwyt0XA78k0sXcRqSHsCB2FZ+6Tm7zncAA4PHoMfVid58Xs6JPUSe3uU/p5DYvBd5vZhuBEHCzu1fErupT08lt/irwczP7MpFhlOt68x95ZvY7IsN/udHjJLcC/QDc/V4ix00uB7YBtcAnu/T9e/HPTkREulhfHD4SEZGTpFAQEZEWCgUREWmhUBARkRYKBRERaaFQEDkJZvZFM9tkZg/HuhaRrqRTUkVOgpltBi6LXjV8vLaJ7h7qhrJETpl6CiInyMzuJXIr58VmdtjMfmNmL5rZVjP7TLTNnOg9/h8B1se0YJEToJ6CyEmI3k+pCLgR+Gci91ZKJzKXwUwit5d4Bpjamd6ESE+hnoLIqfuju9e5+0HgJSJzAAC8pkCQ3kahIHLq2na3316u6e5CRE6VQkHk1M03s1QzyyFyI7OVMa5H5KQpFERO3WtEjh8sB+5w9149HaTENx1oFjkFZnYbcNTd74p1LSJdQT0FERFpoZ6CiIi0UE9BRERaKBRERKSFQkFERFooFEREpIVCQUREWvwv1KrnlduOOYUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.title(\"roc curve\") \n",
    "plt.xlabel(\"fpr\") \n",
    "plt.ylabel(\"tpr\") \n",
    "plt.plot(fpr,tpr) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "auc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7994955130019205"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "metrics.auc(fpr, tpr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7994955130019205"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "roc_auc_score(y,y_proba[:,1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "accuracy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_pred = lgbm.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7200231572004403"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "accuracy_score(y_pred,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 4.3 保存模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "pickle.dump(lgbm,open(\"./model/lgbm.pkl\",\"wb\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 遇到的坑"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "lgbm模型是否可以把数据分批送进去训练，如何计算最优划分点呢？  \n",
    "不可以"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意计算auc需要输出概率！predict_proba"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ValueError: bad input shape (2459135, 2)  \n",
    "y_proba是两列，分别是预测为0和1的概率"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "TypeError: 'numpy.float64' object is not iterable  \n",
    "accuracys写成accuracy，aucs写成auc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ValueError: continuous format is not supported  \n",
    "y必须为数值型变量，作roc曲线时把tpr赋值给y了。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
